#include <iostream>
using namespace std;


/**
 * 
 * 一个月有多少天
 */
int main() {
    int y, m;
    cin >> y >> m;
    if (m == 4 || m == 6 || m == 9 || m == 11) {
        cout << "30" << endl;
    } else if (m == 2) {
        if (y % 100 != 0 && y % 4 == 0 || y % 400 == 0) {
            cout << "29" << endl;
        } else {
            cout << "28" << endl;
        }
    } else {
        cout << "31" << endl;
    }
    return 0;
}